package com.huawei.gamebox.service.common.uikit.activity;

import android.app.ActionBar;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;
import com.huawei.android.app.ActionBarEx;
import com.huawei.appgallery.foundation.ui.framework.activity.AbstractBaseActivity;
import com.huawei.gamebox.framework.cardkit.fragment.BaseGsListFragment.c;
import com.huawei.gamebox.framework.cardkit.fragment.CardListFragment;
import com.huawei.gamebox.framework.cardkit.fragment.CardListFragmentProtocol;
import com.huawei.gamebox.framework.cardkit.fragment.CardListFragmentProtocol.Request;
import com.huawei.gamebox.service.common.uikit.protocol.CardListActivityProtocol;
import o.azb;
import o.azc;
import o.cgv;
import o.cjk;
import o.cjm;
import o.cjo;
import o.dgh;
import o.Logger;
import o.dof;
import o.ean;
import o.exp$c;
import o.exp$e;
import o.exp$f;
import o.exp.d;
import o.exp.j;
import o.eyn;
import o.fay;
import o.fba;

public class CardListActivity extends AbstractBaseActivity<CardListActivityProtocol> implements eyn, c {
    private int ʻॱ = -1;
    private int ˊॱ = -1;
    private boolean ˋॱ;
    private String ˏॱ;
    private View ͺ;
    private String ॱˊ;
    private long ॱˋ;
    private boolean ॱˎ = false;
    private TextView ᐝॱ;

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(j.ʿ);
        if (bundle != null) {
            this.ॱˎ = bundle.getBoolean("key_menu");
        }
        CardListActivityProtocol cardListActivityProtocol = (CardListActivityProtocol) ʾ();
        if (cardListActivityProtocol != null && cardListActivityProtocol.ˊ() != null) {
            ˏ(cardListActivityProtocol);
            ˋ(cardListActivityProtocol);
        }
    }

    public void onResume() {
        super.onResume();
        this.ॱˋ = dgh.ॱ();
    }

    public void onPause() {
        super.onPause();
        CardListActivityProtocol cardListActivityProtocol = (CardListActivityProtocol) ʾ();
        if (cardListActivityProtocol != null && cardListActivityProtocol.ˊ() != null) {
            ean.ˏ(cardListActivityProtocol.ˊ().ʿ(), System.currentTimeMillis() - this.ॱˋ, ʿ());
        }
    }

    private cjm ˊ(CardListActivityProtocol cardListActivityProtocol) {
        cjo cardListFragmentProtocol = new CardListFragmentProtocol();
        cardListFragmentProtocol.ˏ(ˎ(cardListActivityProtocol.ˊ()));
        return new cjm(cardListActivityProtocol.ˋ(), cardListFragmentProtocol);
    }

    private void ˋ(CardListActivityProtocol cardListActivityProtocol) {
        CardListFragment cardListFragment = (CardListFragment) cjk.ˎ().ˊ(ˊ(cardListActivityProtocol));
        if (cardListFragment != null) {
            cardListFragment.ˋ(ˏॱ(), d.ˊᐝ, "cardlist_fragment");
        }
    }

    private Request ˎ(CardListActivityProtocol.Request request) {
        Request request2 = new Request();
        request2.ˊ(request.ॱˊ());
        request2.ˋ(request.ᐝ());
        request2.ॱˊ(request.ˏ());
        request2.ˋॱ(request.ˎ());
        request2.ˊ(request.ˊॱ());
        request2.ॱ(request.ʽ());
        request2.ˊ(request.ॱॱ());
        request2.ॱॱ(request.ˏॱ());
        request2.ॱ(request.ʼ());
        request2.ˎ(request.ʻ());
        request2.ʽ(request.ˋॱ());
        request2.ᐝ(request.ͺ());
        request2.ʻॱ(request.ॱˎ());
        request2.ॱᐝ(request.ॱᐝ());
        request2.ˏ(false);
        request2.ॱ(false);
        if (!ॱ(request.ᐝ(), request2)) {
            request2.ˋ(request.ʻॱ());
            request2.ᐝ(request.ॱˋ());
        }
        return request2;
    }

    private boolean ॱ(String str, Request request) {
        if (TextUtils.isEmpty(str) || !str.startsWith("gss|forum_welfare|")) {
            return false;
        }
        request.ˋ(exp$e.ˋॱ);
        request.ᐝ(exp$f.ᐝˋ);
        return true;
    }

    private void ˏ(CardListActivityProtocol cardListActivityProtocol) {
        this.ͺ = findViewById(d.ˋˊ);
        azb.ˏ(this.ͺ);
        this.ᐝॱ = (TextView) this.ͺ.findViewById(d.ߴ);
        CardListActivityProtocol.Request ˊ = cardListActivityProtocol.ˊ();
        this.ˊॱ = ˊ.ˋ();
        this.ॱˊ = ˊ.ˊ();
        this.ˋॱ = ˊ.ॱ();
        this.ˏॱ = ˊ.ˏॱ();
        this.ʻॱ = ˊ.ᐝॱ();
        ᐝ();
    }

    private void ᐝ() {
        if (azc.ˎ().ॱ() >= 21) {
            ॱˊ();
        } else {
            ͺ();
        }
        cgv.ˋ(this, exp$c.ॱ, exp$c.ᐝ);
    }

    public void ˋ(String str) {
        this.ˏॱ = str;
        if (dof.ॱ(str)) {
            str = getString(exp$f.ˎ);
        }
        ActionBar actionBar = getActionBar();
        if (actionBar != null) {
            actionBar.setTitle(str);
        }
        if (this.ᐝॱ != null) {
            this.ᐝॱ.setText(str);
        }
    }

    private void ॱˊ() {
        this.ͺ.setVisibility(8);
        ActionBar actionBar = getActionBar();
        if (actionBar != null) {
            actionBar.setDisplayOptions(12);
            actionBar.setDisplayShowCustomEnabled(false);
            actionBar.show();
            if (dof.ॱ(this.ˏॱ)) {
                actionBar.setTitle(exp$f.ˎ);
            } else {
                actionBar.setTitle(this.ˏॱ);
            }
        }
        if (this.ˋॱ) {
            ActionBarEx.setEndIcon(actionBar, true, getResources().getDrawable(this.ˊॱ), new OnClickListener(this) {
                final /* synthetic */ CardListActivity ˎ;

                {
                    this.ˎ = r1;
                }

                public void onClick(View view) {
                    this.ˎ.ˏ(this.ˎ.ॱˊ);
                }
            });
            if (this.ʻॱ > 0) {
                try {
                    getWindow().getDecorView().findViewById(16908296).setContentDescription(getString(this.ʻॱ));
                } catch (Exception e) {
                    Logger.e("CardListActivity", "setContentDescription error");
                }
            }
        } else if (this.ॱˎ) {
            ˎ(true);
        } else {
            ActionBarEx.setEndIcon(actionBar, false, null, null);
        }
    }

    private void ͺ() {
        ActionBar actionBar = getActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }
        if (dof.ॱ(this.ˏॱ)) {
            this.ᐝॱ.setText(exp$f.ˎ);
        } else {
            this.ᐝॱ.setText(this.ˏॱ);
        }
        findViewById(d.ᐝˊ).setOnClickListener(new OnClickListener(this) {
            final /* synthetic */ CardListActivity ˋ;

            {
                this.ˋ = r1;
            }

            public void onClick(View view) {
                this.ˋ.onBackPressed();
            }
        });
        ImageView imageView = (ImageView) findViewById(d.ﾟ);
        View findViewById = findViewById(d.ꓸ);
        if (this.ˋॱ) {
            findViewById.setVisibility(0);
            imageView.setBackgroundResource(this.ˊॱ);
            if (this.ʻॱ > 0) {
                findViewById.setContentDescription(getString(this.ʻॱ));
            }
            findViewById.setOnClickListener(new OnClickListener(this) {
                final /* synthetic */ CardListActivity ॱ;

                {
                    this.ॱ = r1;
                }

                public void onClick(View view) {
                    this.ॱ.ˏ(this.ॱ.ॱˊ);
                }
            });
        } else if (this.ॱˎ) {
            ˎ(true);
        } else {
            findViewById.setVisibility(8);
        }
    }

    public String ʿ() {
        CardListActivityProtocol cardListActivityProtocol = (CardListActivityProtocol) ʾ();
        if (cardListActivityProtocol == null || cardListActivityProtocol.ˊ() == null) {
            return null;
        }
        return cardListActivityProtocol.ˊ().ᐝ();
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (16908332 != menuItem.getItemId()) {
            return super.onOptionsItemSelected(menuItem);
        }
        finish();
        return true;
    }

    public void ˎ(boolean z) {
        if (z) {
            int i = exp$e.ͺ;
            Drawable drawable = getResources().getDrawable(i);
            if (azc.ˎ().ॱ() >= 21) {
                ActionBarEx.setEndIcon(getActionBar(), true, drawable, ᐝॱ());
                try {
                    getWindow().getDecorView().findViewById(16908296).setContentDescription(getString(exp$f.ٴ));
                } catch (Exception e) {
                    Logger.e("CardListActivity", "setContentDescription error");
                }
            } else {
                View findViewById = this.ͺ.findViewById(d.ꓸ);
                findViewById.setVisibility(0);
                ((ImageView) findViewById.findViewById(d.ﾟ)).setImageResource(i);
                findViewById.setContentDescription(getString(exp$f.ٴ));
                findViewById.setOnClickListener(ᐝॱ());
            }
            this.ॱˎ = z;
        }
    }

    private OnClickListener ᐝॱ() {
        return new OnClickListener(this) {
            final /* synthetic */ CardListActivity ˋ;

            {
                this.ˋ = r1;
            }

            public void onClick(View view) {
                this.ˋ.ˏ("campaigntoawardevent");
            }
        };
    }

    private void ˏ(String str) {
        if (str != null) {
            fay ˎ = fba.ˎ(str);
            if (ˎ != null) {
                ˎ.ˋ(this, false);
            }
        }
    }

    public void onSaveInstanceState(Bundle bundle) {
        bundle.putBoolean("key_menu", this.ॱˎ);
        super.onSaveInstanceState(bundle);
    }
}
